package com.jay.media.music.core.player

/**
 * 媒体播放器通用接口
 *
 *
 * 具体实现根据需求采用 MediaPlayer/ExoPlayer/ijkPlayer
 */
interface IMediaPlayer {
    /**
     * Prepares the player to play
     *
     * @param uri the path of the file, or the http/rtsp URL of the stream you want to play
     */
    fun prepare(uri: String)

    /**
     * Starts or resumes playback.
     */
    fun play()

    /**
     * Pauses playback.
     */
    fun pause()

    /**
     * Resume playback.
     */
    fun resume()

    /**
     * Seeks to specified time position.
     *
     * @param msec the offset in milliseconds from the start to seek to
     */
    fun seekTo(msec: Long)

    /**
     * Stops playback without resetting the player.
     */
    fun stop()

    /**
     * Releases resources associated with this MediaPlayer object.
     */
    fun release()

    /**
     * Returns the audio session ID.
     */
    fun getAudioSessionId(): Int

    /**
     * Gets the duration of the file.
     *
     * @return the duration in milliseconds.
     */
    fun getDuration(): Long

    /**
     * Gets the current playback position.
     *
     * @return the current position in milliseconds
     */
    fun getContentPosition(): Long

    /**
     * Returns an estimate of the position in the current content window or ad up to which data is
     * buffered, in milliseconds.
     */
    fun getBufferedPosition(): Long

    /**
     * Register a player event listener
     *
     * @param listener the listener
     */
    fun setPlayerEventListener(listener: IPlayerEventListener?)

    /**
     * Register a listener for changes in audio configuration.
     * (Only for ExoPlayer)
     *
     * @param listener the listener
     */
    fun setAudioListener(listener: IAudioListener?)
}